/*document.cookie="token=yes"*/
 function getUrlParam(b) {
	 var c = new RegExp("(^|&)" + b + "=([^&]*)(&|$)","i");
	 var a = window.location.search.substr(1).match(c);
	 if (a != null && a[2] != "null") {
	     return decodeURIComponent(a[2])
	 }
	 return null
}

//var baseUrl = "http://www.tpglxtsix.top/";  
var baseUrl = "http://tp1.dfybjkj.top/"; 

var actid = getUrlParam('activityid');
var openid = localStorage.getItem("openid");
var access_token = localStorage.getItem("access_token");
var code = getUrlParam('code');
if(openid == null){
	if(code == null){
		$.ajax({
			url: baseUrl + 'vote-admin/free/getAuthorizeUrl',
			type: 'get',
			data:{
				activityid: actid
			},
			success:function(res){
				window.location.href = res.authorizeUrl
			}
		})
	}
	else{
		$.ajax({
			url: baseUrl + 'vote-admin/free/getOpenid',
			type: 'get',
			data:{
				code: code
			},
			success:function(res){
				localStorage.setItem("openid",res.openid);
				localStorage.setItem("access_token",res.access_token);
				window.location.reload();
			}
		})
	}
	
}
else{
	$.ajax({
		url: baseUrl + 'vote-admin/free/getUserInfo',
		type: 'get',
		data:{
			openid: openid,
			access_token: access_token
		},
		success:function(res){
			console.log(res);
		}
	})
}
var config = function config(){
	var arr = "";
	$.ajax({
		url: baseUrl + 'vote-admin/free/getSharePram',
		type: 'get',
		async: false,
		cache: false,
		data:{
			url: location.href.split('#')[0]
		},
		success:function(res){
			arr = res
		}
	})
	return arr;
}


